import 'dart:async';

import 'package:flutter/material.dart';
import 'package:test2/util/toast.dart';

abstract class BaseState<T extends StatefulWidget> extends State<T>
    with TickerProviderStateMixin {
  void showToast(msg) {
    SimpleToast(message: msg).show(context);
  }

  void startPage(page) {
    Navigator.of(context).push(MaterialPageRoute(builder: (context) => page));
  }

  void replacePage(page) {
    Navigator.of(
      context,
    ).pushReplacement(MaterialPageRoute(builder: (context) => page));
  }

  void replaceAllPage(page) {
    Navigator.of(context).pushAndRemoveUntil(
      MaterialPageRoute(builder: (context) => page),
          (route) {
        return false;
      },
    );
  }

  void finish([T? result]) {
    Navigator.of(context).pop(result);
  }
}
